package com.briup.day15;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class Test_LinkedList {
        public static void main(String[] args) {
//操作集合的次数
            final int NUM = 100000;
//1.实例化集合对象
//            List<String> list = new ArrayList<>();
List<String> list = new LinkedList<>();
//2.开启计时，往集合种放入 100000 个元素
            long start1 = System.currentTimeMillis();
            for (int i = 0; i < NUM; i++) {
                list.add(0, "hello" + i);
                list.getClass().getSimpleName();
            }
            long end1 = System.currentTimeMillis();
//3.输出时长
            System.out.println(list.getClass().getSimpleName() + "插 入" + NUM + "条数据耗时" + (end1 - start1) + "毫秒");
//4.开启计时，从集合种取 100000 个元素
            long start2 = System.currentTimeMillis();
            for (int i = 0; i < list.size(); i++) {
                list.get(i);
            }
            long end2 = System.currentTimeMillis();
//5.输出时长
            System.out.println(list.getClass().getSimpleName() + "检 索" + NUM + "条数据耗时" + (end2 - start2) + "毫秒");
        }
}
